package com.shipxpress.register.web;

import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.SessionAware;
import com.opensymphony.xwork2.Action;
import com.shipxpress.SessionManager;
import com.shipxpress.register.util.UserList;

public class DisplayRegistrationAction implements Action, ServletRequestAware, SessionAware{

    private HttpSession session;
    private Map<String, Object> sessionMap;
    private UserList duplicateUserList;

    public UserList getDuplicateUserList() {
        return duplicateUserList;
    }

    public String execute() throws Exception {
        UserList userList = (UserList)session.getAttribute("userList");
        duplicateUserList = userList;
        System.out.println("You're user list is growing. now the size of the list is : " + userList.size());
        System.out.println("You're user list is growing. now the size of the list from session map is : " +
                SessionManager.getSessionUserList(sessionMap).size());
        return SUCCESS;
    }

    public void setServletRequest(HttpServletRequest httpServletRequest) {
        session = httpServletRequest.getSession();
    }

    public void setSession(Map<String, Object> sessionMap) {
        this.sessionMap = sessionMap;
    }
}
